package com.service.impl;

import com.Dto.GuidanceSessionOfSupervisorDto;
import com.Dto.SupervisorInfoDto;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.*;
import com.pojo.CounselorBound;
import com.pojo.Supervisor;
import com.service.SupervisorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;


/**
 * 督导相关功能
 */
@Service
public class SupervisorServiceImpl extends ServiceImpl<SupervisorMapper, Supervisor> implements SupervisorService {

    //查询督导的排班
    @Autowired
    private SupervisorMapper supervisorMapper;

    @Autowired
    private SupervisorSchedulingMapper supervisorSchedulingMapper;

    @Autowired
    private GuidanceSessionMapper guidanceSessionMapper;

    @Autowired
    private CounselorBoundMapper counselorBoundMapper;

    @Autowired
    private SupervisorInfoMapper supervisorInfoMapper;

    public List<LocalDate> getDatesByUserIdAndCurrentMonth(Integer userId){
        Supervisor supervisor = supervisorMapper.findSupervisorByUserId(userId);

        List<LocalDate> dateList = supervisorSchedulingMapper.findDatesBySupervisorId(supervisor.getId());
            return dateList;
    }

    public List<GuidanceSessionOfSupervisorDto> getGuidanceSessionByUserId(Integer userId){
        Supervisor supervisor = supervisorMapper.findSupervisorByUserId(userId);

        List<GuidanceSessionOfSupervisorDto> sessionList = guidanceSessionMapper.getGuidanceSessionsBySupervisor(supervisor.getId());
            return sessionList;
    }

    public List<CounselorBound> getCounselorBound(Integer userId){
        List<CounselorBound> counselorBoundList = counselorBoundMapper.findCounselorBound(userId);
            return counselorBoundList;
    }

    //督导查询个人信息
    public List<SupervisorInfoDto> getSupervisorInfoByUserId(Integer userId) {
        Supervisor supervisor = supervisorMapper.findSupervisorByUserId(userId);
       List<SupervisorInfoDto> supervisorInfo = supervisorInfoMapper.findSupervisorInfo(supervisor.getId());
       return supervisorInfo;
    }

}
